package com.example.android.commitcontent.ime.dict.comparators;

import com.example.android.commitcontent.ime.beans.HanZiCharacter;

import java.util.Comparator;

/**
 * 汉字排序器
 */
public class HanZiComparator implements Comparator<HanZiCharacter> {

    private HanZiComparator() {
    }

    public static HanZiComparator newInstance() {
        return new HanZiComparator();
    }

    @Override
    public int compare(HanZiCharacter hanZi1, HanZiCharacter hanZi2) {
        //词频数相同通过笔画数来筛选
        if (hanZi1.repeatCount == hanZi2.repeatCount)
            return hanZi1.bihua - hanZi2.bihua;
        return hanZi2.repeatCount - hanZi1.repeatCount;
    }
}
